public class Solve2 {
    // 大数加法
    // https://www.nowcoder.com/practice/11ae12e8c6fe48f883cad618c2e81475?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page
    public String solve (String s, String t) {
        // write code here
        if (s.length() == 0) {
            return t;
        }
        if (t.length() == 0) {
            return s;
        }
        StringBuilder ret = new StringBuilder();
        char[] c1 = s.toCharArray();
        char[] c2 = t.toCharArray();
        int index1 = c1.length-1;
        int index2 = c2.length-1;
        int tmp = 0;
        while (index1 >= 0 || index2 >= 0 || tmp != 0) {
            int num1 = index1 >= 0 ? c1[index1--] - '0' : 0;
            int num2 = index2 >= 0 ? c2[index2--] - '0' : 0;
            int sum = num1 + num2 + tmp;
            ret.append(sum % 10);
            tmp = sum / 10;
        }
        return ret.reverse().toString();
    }
}
